<docs>
  ##
</docs>
<template>
  <div class="content">
    <div class="header">
      <span class="arrow" @click="back_btn"></span>
      <h3 class="title">单位详情</h3>
    </div>
    <div class="common margin">
      <div class="title tem_comm">
        <p>
          <i></i>公司信息
          <span
            class="sc"
            :class="[dwxx.sfdl=='0' ? 'not_allowed':'']"
            @click="sight(dwxx.sfdl)"
          >
            {{sightTxt}}
            <img src="~common/images/sc.png" alt />
          </span>
          <span class="gw" v-if="dwxx.lxrsj" @click="jump">
            <!-- <a :href="'tel:' + dwxx.lxrsj">一键联系</a> -->
            一键联系
            <img src="~common/images/phone.png" alt />
          </span>
        </p>
      </div>
      <div class="pos_com tem_comm">
        <p>
          <span>单位名称：</span>
          {{dwxx.dwmc}}
        </p>
        <p>
          <span>单位性质：</span>
          {{dwxx.dwxz_xs}}
        </p>
        <!-- <p>
          <span>单位规模：</span>
          {{dwxx.qygm_xs}}
        </p> -->
        <p>
          <span>单位行业：</span>
          {{dwxx.dwhy_xs}}
        </p>
        <!-- <p>
          <span>单位类型：</span>
          {{dwxx.dwlx_xs}}
        </p>-->
        <p>
          <span>经营地址：</span>
          {{dwxx.jydz}}
        </p>
        <!-- <p>
          <span>主营业务：</span>
          {{dwxx.zyyw}}
        </p> -->
      </div>
      <div class="bgc">
        <position
          v-for="(item, index) in gwxxlb"
          :key="index"
          :job="item.gwmc"
          :money="item.xcfw"
          :gzdq="item.gzdq"
          :xl="item.whcd"
          :sfytdjl="item.sfytdjl"
          :zpgwid="item.zpgwid"
          :dwdjid="item.dwdjid"
          :sftxtdjl="item.sftxtdjl"
          :zplxrdh="item.zplxrdh"
          :sfyjycsqy="dwxx.sfyjycsqy"
          :sfdl="dwxx.sfdl"
          :ygxs="item.ygxs"
          sfdwxx="1"
          v-model="val"
          @link="link_bank"
        ></position>
        <div class="comMess" v-show="gwxxlb.length == 0">
          <div>该公司暂无招聘信息</div>
        </div>
      </div>
    </div>
    <!-- 投递简历弹框 -->
    <sub-confirm :visible.sync="visibleResume" :jlxx="jlxx" @qrtd="toudi"></sub-confirm>
  </div>
</template>
<script>
import Position from "base/job/jobList";
import $ from "@/common/js/axios";
import viewNum from '@/common/js/configuration';

export default {
  name: "newcompanyDetail",
  components: { Position },
  data() {
    return {
      val: {},
      zpgws: "",
      visibleResume: false,
      jlxx: {},
      sightFlag: "",
      sightTxt: "关注",
      grqzid: "",
      dwxx: {
        dwmc: "",
        qygm_xs: "",
        dwhy_xs: "",
        dwlx_xs: "",
        jydz: "",
        zyyw: "",
        dwdjid: ""
      },
      gwxxlb: [],
      qwss: "",
      gwxx: {
        jlid: "",
        zpgwid: "",
        sftxtdjl: ""
      }
    };
  },
  watch: {
    val: function(val) {
      this.gwxx.zpgwid = val.zpgwid;
      this.gwxx.sftxtdjl = val.sftxtdjl;

      if (val.sftxtdjl === "0") {
        this.visibleResume = true;
      } else {
        this.visibleResume = false;
        this.toudi(1);
      }
    }
  },
  methods: {
    // 一键联系
    jump() {
      if (this.dwxx.sfdl == 1) {
        viewNum('2014000')
        // 判断是否登录，没有登录
        if (this.dwxx.lxdhtx) {
          this.$alert(this.dwxx.lxdhtx);
        }else{
          const href = `tel:${this.dwxx.lxrsj}`;
          var a = document.createElement("a");
          a.setAttribute("href", href);
          document.body.appendChild(a);
          a.click();
        }
      } else {
        window.location.href = "./public3.html";
        // window.location.href = './login.html';
      }
    },
    // link_bank跳转
    link_bank(gwid, dwid) {
      this.$router.push({
        name: "newjobDetail",
        query: { dm: gwid, _id: dwid }
      });
    },
    // 投递简历
    toudi(data) {
      this.$loading = true;
      data ? (this.gwxx.sftxtdjl = "1") : (this.gwxx.sftxtdjl = "0");
      $.post("/grgl/jltdxxBc", this.gwxx)
        .then(res => {
          if (+res.returnCode === 1) {
            this.visibleResume = false;
            this.$alert(res.returnData.message);
            this.Get_position();
          }
        })
        .finally(() => {
          this.$loading = false;
        });
    },
    // 关注
    sight(n) {
      if (n == 0) return;
      var form = {
        zpgws: this.zpgws,
        grqzid: this.grqzid,
        dwdjid: this.dwxx.dwdjid,
        sfgz: (this.sightFlag = this.sightFlag == "1" ? "0" : "1")
      };
      $.post("/grgl/zpdwgzBc", form).then(res => {
        const data = res.returnData;
        if (+data.executeResult === 1) {
          if (this.sightFlag == "0") {
            this.sightFlag == "1";
            this.sightTxt = "关注";
          } else {
            this.sightFlag == "0";
            this.sightTxt = "已关注";
          }
          this.$toast(data.message);
        } else {
          this.$toast(data.message);
        }
      });
    },
    // 获取单位信息
    GET_message() {
      $.get("/grcptj/zpdwxxCx", {
        params: {
          dwdjid: this.qwss
        }
      })
        .then(res => {
          const data = res.returnData;
          this.dwxx = data.dwxx;
          //是否收藏简历 标识 1收藏； 0未收藏
          this.sightFlag = this.dwxx.sfygz;
          if (this.sightFlag == "1") {
            this.sightTxt = "已关注";
          } else {
            this.sightTxt = "关注";
          }
        })
        .catch(() => {});
    },
    // 获取招聘信息
    Get_position() {
      $.get("/grcptj/zpgwxxCx", {
        params: {
          dwdjid: this.qwss
        }
      })
        .then(res => {
          const data = res.returnData;
          if (+data.executeResult === 1) {
            this.gwxxlb = data.gwxxlb;
            this.zpgws = data.zpgws;
            this.Resume_list();
          } else {
            this.gwxxlb = [];
          }
        })
        .catch(() => {});
    },
    //获取简历信息列表
    Resume_list() {
      $.get("/grgl/jlxxCx").then(res => {
        const data = res.returnData;
        this.jlxx = data.jlxx;
        this.gwxx.jlid = this.jlxx.jlid;
        this.grqzid = this.jlxx.grqzid;
      });
    },
    back_btn() {
      if (this.$route.query.look == 1) {
        this.$router.push({ path: "/user/tdList", query: { look: "1" } });
      } else {
        this.$router.go(-1);
      }
    }
  },
  created() {
    this.qwss = this.$route.query.id;
    this.GET_message();
    this.Get_position();
  }
};
</script>
<style scoped lang="scss">
@import "~common/scss/var.scss";
.head {
  height: 200px;
  display: flex;
  background-color: #fff;
  border-bottom: 1px solid $color-text-placeholder;
  p {
    width: 80%;
    font-size: $font-size-base;
    color: $color-text-title;
    font-weight: 600;
    align-self: center;
    margin: 0 auto;
    line-height: 1.2;
  }
}
.tab {
  height: 100px;
  line-height: 100px;
  background-color: #fff;
  span {
    display: inline-block;
    box-sizing: border-box;
    float: left;
    text-align: center;
    width: 50%;
    color: $color-text-title;
    font-weight: 600;
    font-size: $font-size-base;
  }
  .tab_c {
    color: $color-base;
    border-right: 1px solid $color-text-placeholder;
  }
  .tab_border {
    color: $color-base;
    border-left: 1px solid $color-text-placeholder;
  }
}
.comMess {
  width: 90%;
  min-height: 1000px;
  margin: 30px auto;
  background-color: #fff;
  p {
    line-height: 40px;
    color: $color-text-primary;
    font-size: 0.34667rem;
    margin-left: 0.53333rem;
    padding-top: 40px;
    width: 90%;
    span {
      font-weight: 700;
      color: #333;
    }
  }
  div {
    padding-top: 50%;
    font-size: $font-size-large;
    color: $color-text-title;
    text-align: center;
  }
}
.common {
  // min-height: 175px;
  background-color: #fff;
  .tem_comm {
    width: 90%;
    margin: 0 auto;
    p {
      font-size: $font-size-base;
    }
  }
  .title {
    height: 90px;
    line-height: 90px;
    border-bottom: 1px solid #dbdbdb;
    font-weight: bold;
    p {
      color: #666;
    }
    i {
      width: 10px;
      height: 30px;
      border-radius: 10px;
      background-color: $color-base;
      margin-right: 10px;
      display: inline-block;
    }
    .sc,
    .gw {
      float: right;
      height: $height-width_line * 2;
      line-height: $height-width_line * 2;
      margin: $height-base / 5 0 0 $height-base / 5;
      background-color: #ff9900;
      padding: 0 $radius-base;
      box-sizing: border-box;
      color: #fff;
      font-size: $padding-base-half * 3;
      border-radius: $padding-base-half;
      img {
        height: $height-base/5;
        width: $height-base/5;
        float: right;
        margin-top: $radius-base;
      }
      a {
        color: #fff;
      }
    }
    .gw img,
    .sc img {
      margin-left: $padding-base/2;
    }
    .not_allowed {
      background-color: #ccc;
    }
  }
  .edu_list {
    line-height: 84px;
    border-left: none;
    p {
      color: $color-text-primary;
    }
  }
  .pos_com {
    line-height: 60px;
    margin: 20px auto 0;
    padding-bottom: 20px;
    // color: #999;
    span {
      font-weight: bold;
      color: #666;
    }
    .span_spac {
      font-weight: normal;
    }
  }
}
.bgc {
  background-color: #eceded;
  padding-top: $padding-base;
}
</style>
